home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / ada / gnat1792.zip / gnat179b / t-adainc / s-tasoli.ads < prev    next >
Text File  |  1994-05-19  |  5KB  |  85 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT COMPILER COMPONENTS                         --
  4. --                                                                          --
  5. --            S Y S T E M . T A S K I N G _ S O F T _ L I N K S             --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.4 $                              --
  10. --                                                                          --
  11. --           Copyright (c) 1992,1993,1994 NYU, All Rights Reserved          --
  12. --                                                                          --
  13. -- GNAT is free software;  you can  redistribute it  and/or modify it under --
  14. -- terms of the  GNU General Public License as published  by the Free Soft- --
  15. -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
  16. -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
  17. -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
  18. -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
  19. -- for  more details.  You should have  received  a copy of the GNU General --
  20. -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
  21. -- to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. --
  22. --                                                                          --
  23. ------------------------------------------------------------------------------
  24.  
  25. --  This package contains a set of subprogram access variables that access
  26. --  some basic tasking primitives that are called from non-tasking code (e.g.
  27. --  the defer/undefer abort that surrounds a finalization action). To avoid
  28. --  dragging in the tasking all the time, we use a system of soft links where
  29. --  the links are initialized to dummy non-tasking versions, and then if the
  30. --  tasking is initialized, they are reset to the real tasking versions.
  31.  
  32. package System.Tasking_Soft_Links is
  33.  
  34.    --  First we have the access subprogram types used to establish the links.
  35.    --  The approach is to establish variables containing access subprogram
  36.    --  values which by default point to dummy no tasking versions of routines.
  37.  
  38.    --  Note: the reason that Get_Address_Call has a dummy parameter is that
  39.    --  there is a bug in GNAT with access to subprograms with no params ???
  40.  
  41.    type No_Param_Proc    is access procedure;
  42.    type Get_Address_Call is access function (Dummy : Boolean) return Address;
  43.  
  44.    --  Declarations for the no tasking versions of the required routines
  45.  
  46.    procedure Abort_Defer_NT;
  47.    --  Defer task abortion (non-tasking case, does nothing)
  48.  
  49.    procedure Abort_Undefer_NT;
  50.    --  Undefer task abortion (non-tasking case, does nothing)
  51.  
  52.    procedure Task_Lock_NT;
  53.    --  Lock out other tasks (non-tasking case, does nothing)
  54.  
  55.    procedure Task_Unlock_NT;
  56.    --  Release lock set by Task_Lock (non-tasking case, does nothing)
  57.  
  58.    function Get_TSD_Address_NT (Dummy : Boolean) return Address;
  59.    --  Obtain pointer to TSD (non-tasking case, gets special global TSD that
  60.    --  is allocated and initialized by the System.Task_Specific_Data package)
  61.  
  62.    Abort_Defer : No_Param_Proc := Abort_Defer_NT'Access;
  63.    --  Defer task abortion (task/non-task case as appropriate)
  64.  
  65.    Abort_Undefer : No_Param_Proc := Abort_Undefer_NT'Access;
  66.    --  Undefer task abortion (task/non-task case as appropriate)
  67.  
  68.    Get_TSD_Address : Get_Address_Call := Get_TSD_Address_NT'Access;
  69.    --  Get pointer to task specific data  (task/non-task case as appropriate)
  70.  
  71.    Lock_Task : No_Param_Proc := Task_Lock_NT'Access;
  72.    --  Locks out other tasks. Preceding a section of code by Task_Lock and
  73.    --  following it by Task_Unlock creates a critical region. This is used
  74.    --  for ensuring that a region of non-tasking code (such as code used to
  75.    --  allocate memory) is tasking safe. Note that it is valid for calls to
  76.    --  Task_Lock/Task_Unlock to be nested, and this must work properly, i.e.
  77.    --  only the corresponding outer level Task_Unlock will actually unlock.
  78.  
  79.    Unlock_Task : No_Param_Proc := Task_Unlock_NT'Access;
  80.    --  Releases lock previously set by call to Lock_Task. In the nested case,
  81.    --  all nested locks must be released before other tasks competing for the
  82.    --  tasking lock are released.
  83.  
  84. end System.Tasking_Soft_Links;
  85.